#include "checker.h"

#define BOOST_AUTO_TEST_MAIN
#define BOOST_TEST_DYN_LINK

#include <boost/test/auto_unit_test.hpp>
#include <boost/test/test_tools.hpp>

BOOST_AUTO_TEST_CASE(symm_checker_test) {
    SymmetricChecker symmetricChecker;
    OnlineSymmetricChecker onlineChecker;
    FinalSymmetricChecker finalChecker;
    ProcessState state;
    state.numVertecies = 2;
    state.vertecies[0] = 0;
    state.vertecies[1] = 1;
    BOOST_CHECK(symmetricChecker.check(state, 0));
    BOOST_CHECK(symmetricChecker.check(state, 1));
    BOOST_CHECK(onlineChecker.check(state));

    state.numVertecies = 1;
    state.vertecies[0] = 1;
    BOOST_CHECK(onlineChecker.check(state));
    BOOST_CHECK(finalChecker.check(state));

    state.numVertecies = 1;
    state.vertecies[0] = 2;
    BOOST_CHECK(!onlineChecker.check(state));
    BOOST_CHECK(!finalChecker.check(state));
 
    state.numVertecies = 2;
    state.vertecies[0] = 0;
    state.vertecies[1] = 2;
    BOOST_CHECK(onlineChecker.check(state));
    BOOST_CHECK(finalChecker.check(state));

    state.numVertecies = 2;
    state.vertecies[0] = 1;
    state.vertecies[2] = 2;
    //can change 2 to zero
    BOOST_CHECK(!onlineChecker.check(state));
    BOOST_CHECK(!finalChecker.check(state));

    state.numVertecies = 3;
    state.vertecies[0] = 0; //000
    state.vertecies[1] = 6; //020
    state.vertecies[2] = 26;//222
    BOOST_CHECK(onlineChecker.check(state));
    BOOST_CHECK(!finalChecker.check(state));

    state.numVertecies = 3;
    state.vertecies[0] = 0; //000
    state.vertecies[1] = 24;//220
    state.vertecies[2] = 26;//222
    BOOST_CHECK(!onlineChecker.check(state));
    BOOST_CHECK(!finalChecker.check(state));

    state.numVertecies = 3;
    state.vertecies[0] = 0; //000
    state.vertecies[1] = 20;//202
    state.vertecies[2] = 26;//222
    BOOST_CHECK(!onlineChecker.check(state));
    BOOST_CHECK(!finalChecker.check(state));
}

BOOST_AUTO_TEST_CASE(coord_symm_checker_test) {
    OnlineSymmetricCoordChecker checker;
    ProcessState state;
    state.numVertecies = 1;
    state.vertecies[0] = 0;
    BOOST_CHECK(checker.check(state));
    state.vertecies[0] = 1;
    BOOST_CHECK(checker.check(state));
    state.vertecies[0] = 2;
    BOOST_CHECK(checker.check(state));
    state.vertecies[0] = 3;
    BOOST_CHECK(!checker.check(state));
    state.vertecies[0] = 4;
    BOOST_CHECK(checker.check(state));
    state.vertecies[0] = 5;
    BOOST_CHECK(checker.check(state));
    state.vertecies[0] = 6;
    BOOST_CHECK(!checker.check(state));

    state.numVertecies = 2;
    state.vertecies[0] = 0;
    state.vertecies[1] = 1;
    BOOST_CHECK(checker.check(state));
    state.vertecies[1] = 2;
    BOOST_CHECK(checker.check(state));
    state.vertecies[1] = 6; //020
    BOOST_CHECK(!checker.check(state));
    state.vertecies[1] = 24; //220
    BOOST_CHECK(!checker.check(state));
    state.vertecies[1] = 20; //202
    BOOST_CHECK(!checker.check(state));
    state.vertecies[1] = 26; //222
    BOOST_CHECK(checker.check(state));
    state.vertecies[1] = 13; //111
    BOOST_CHECK(checker.check(state));
    state.vertecies[1] = 12; //110
    BOOST_CHECK(!checker.check(state));
    state.vertecies[1] = 3; //010
    BOOST_CHECK(!checker.check(state));
    state.vertecies[1] = 10; //101
    BOOST_CHECK(!checker.check(state));
    state.vertecies[0] = 5; //012
    state.vertecies[1] = 7; //021
    BOOST_CHECK(checker.check(state));
    state.vertecies[0] = 2;  //002
    state.vertecies[1] = 22; //211
    BOOST_CHECK(!checker.check(state));


    state.numVertecies = 3;
    state.vertecies[0] = 0; //000
    state.vertecies[1] = 24;//220
    state.vertecies[2] = 26;//222
    BOOST_CHECK(!checker.check(state));

    state.vertecies[0] = 0; //000
    state.vertecies[1] = 20;//202
    state.vertecies[2] = 26;//222
    BOOST_CHECK(!checker.check(state));

    state.numVertecies = 3;
    state.vertecies[0] = 0; //000
    state.vertecies[1] = 6; //020
    state.vertecies[2] = 26;//222
    BOOST_CHECK(!checker.check(state));

    state.numVertecies = 3;
    state.vertecies[0] = 2;  //0002
    state.vertecies[1] = 42; //1120
    state.vertecies[2] = 46; //1201
    BOOST_CHECK(checker.check(state));

    state.numVertecies = 3;
    state.vertecies[0] = 2;  //0002
    state.vertecies[1] = 42; //1120
    state.vertecies[2] = 64; //2101
    BOOST_CHECK(!checker.check(state));
}
